package fr.appliClient.server.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "ENTRETIEN")
public class Maintenance implements AbstractEntity<Long>, Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_entretien")
	private Long id;

	@Column(name = "libelle")
	private String name;

	@Column(name = "date_entretien")
	@Temporal(value = TemporalType.DATE)
	private Date date;

	@Column(name = "cout")
	private Float cost;

	@Column(name = "kilometrage")
	private Float mileage;

	@Column(name = "rapport")
	private String report;

	@ManyToOne
	@JoinColumn(name = "vehicule_fk")
	private Vehicle vehicle;

	public Maintenance() {

	}

	public String getName() {

		return name;
	}

	public void setName(String name) {

		this.name = name;
	}

	public Date getDate() {

		return date;
	}

	public void setDate(Date date) {

		this.date = date;
	}

	public Float getCost() {

		return cost;
	}

	public void setCost(Float cost) {

		this.cost = cost;
	}

	public Float getMileage() {

		return mileage;
	}

	public void setMileage(Float mileage) {

		this.mileage = mileage;
	}

	public Vehicle getVehicle() {

		return vehicle;
	}

	public void setVehicle(Vehicle vehicule) {

		if (vehicule != null) {
			this.vehicle = vehicule;
			if (!vehicule.getMaintenances().contains(this)) {
				vehicule.getMaintenances().add(this);
			}
		}
	}

	public String getReport() {

		return report;
	}

	public void setReport(String report) {

		this.report = report;
	}

	public Long getId() {

		return id;
	}

}
